package com.cqan.service.impl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cqan.dao.AtomFieldDao;
import com.cqan.entity.AtomField;
import com.cqan.orm.Page;
import com.cqan.service.AtomFieldService;

@Service("atomFieldService")
public class AtomFieldServiceImpl extends EntityServiceImpl<AtomField, Long, AtomFieldDao>
		implements AtomFieldService {

	@Override
	@Autowired
	public void setEntityDao(AtomFieldDao entityDao) {
		this.entityDao = entityDao;
	}

	public AtomField findFieldByAttNameAndReportId(String attrName, Long rid) {
		return entityDao.findUnique("from Field f where f.value = ? and f.report.id=?", attrName,rid);
	}

	public Page<AtomField> reportFields(Long rid, Page<AtomField> page) {
		
		return entityDao.findPage(page, "from Field f where f.report.id=? order by f.id desc", rid);
	}


}
